package com.zhaopin.gitlab;

import com.zhaopin.utils.FileUtil;
import com.zhaopin.utils.GitUtils;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;

public class JustTag {

        static String projectName = "project";
//    static String projectName = "position";
    static String outputDir = projectName.equals("project") ? "dir/gitlab/recommend" : "dir/gitlab/position";

    public static void main(String[] args) throws IOException {

        String gitFile = "/Users/zhaopin/IdeaProjects/" + projectName + "/%s";

        List<String> projectNameList = FileUtils.readLines(new File(outputDir + "/" + projectName + "_need_update_project.txt"), Charset.defaultCharset());


        List<String> realProjectNameList = new ArrayList<>();
        for (String s : projectNameList) {
            if (s.contains(":")) {
                realProjectNameList.add(s.split(":")[0]);
            }

        }

        for (String s : realProjectNameList) {
            //获取项目的目录
            String gitFileNew = String.format(gitFile, s);
            File gitFileM = new File(gitFileNew);
            //首先拉取
            GitUtils.gitPull(gitFileM);
            GitUtils.getPushWithTag(gitFileM,  "master-v0.0.1-", true);

        }

    }
}
